package cn.chengdu.mapper;

import cn.chengdu.entity.Staffinfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 医院员工信息表 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-11-25
 */
@Mapper
public interface StaffinfoMapper extends BaseMapper<Staffinfo> {


    @Select({
            "select p.postitle,s.staname,s.smiaoshu,s.surplusnum from hospital_public.staffinfo s left join system.workersandemployeeinformation w on s.staid=w.staid left join system.position p on w.posid=p.posid where s.depid=#{depid}"
    })
    List<Staffinfo> getdoctor(int depid);
//更新剩余挂号数
    @Update("update hospital_public.staffinfo set surplusnum=surplusnum-1 where depid=#{depid} ")
    public int updateSurnum(Staffinfo staffinfo);

    //设置新的挂号数
    @Update("update hospital_public.staffinfo set surplusnum=50 where depid=#{depid} ")
    public int updateSurnum5(Staffinfo staffinfo);
//    查询剩余号数
    @Select("select surplusnum from hospital_public.staffinfo where staid=#{staid}")
    public Staffinfo findSnum(Staffinfo staffinfo);
}
